<?

require_once ("application.fieldset.inc");

global $_GLOBAL_DBH;
global $_OBJECT_IFACE_PANEL;

$fieldset_tasks = new Fieldset (array (
	db_conn=>$_GLOBAL_DBH,
	relation=>"tasks",
	fieldset=>array (
		array (name=>"id",label=>"ID",type=>"numeric",
				value=>$_REQUEST["task_id"],
				input=>"hidden",primary_key=>true),
		array (name=>"user_id",label=>"Owner ID",type=>"numeric",
				value=>$_APP_SESSION_USER->id,
				input=>"hidden"),
		array (name=>"title",label=>"Title",type=>"alphanumeric",
				input=>"field"),
		array (name=>"details",label=>"Details",type=>"alphanumeric",
				input=>"textarea",rows=>3),
		array (name=>"status",label=>"Status",type=>"character",
				input=>"select",
				value=>"new",
				options=>array (
					array (id=>"active",name=>"Active"),
					array (id=>"inactive",name=>"Inactive"),
					array (id=>"hold",name=>"Hold"),
					array (id=>"suspended",name=>"Suspended"),
					array (id=>"processing",name=>"Processing"),
					array (id=>"new",name=>"New"),
					array (id=>"assigned",name=>"Assigned"),
					array (id=>"started",name=>"Started"),
					array (id=>"stopped",name=>"Stopped"),
					array (id=>"complete",name=>"Complete"),
				),
				columns=>array(key=>"id",value=>"name"),
		),
		array (name=>"date_begin",label=>"Date Begin",type=>"any",
				input=>"date",value=>_app_date("date_begin")),
		array (name=>"date_end",label=>"Date End",type=>"any",
				input=>"date",value=>_app_date("date_end")),
		array (name=>"date_due",label=>"Date Due",type=>"any",
				input=>"date",value=>_app_date("date_due")),
	)
));

$fieldset_tasks->parse ();

$return = "/fs_tasks.php?fs_action=view&fs_tab=main&task_id={$_REQUEST["task_id"]}";

$fs_options = array (
	addnew=>array (label=>"Add New"),
	create=>array (label=>"Create"),
	modify=>array (label=>"Modify"),
	remove=>array (label=>"Remove"),
	update=>array (label=>"Update"),
	cancel=>array (label=>"Cancel"),
	delete=>array (label=>"Delete",
			redirect=>dirname ($_SERVER["PHP_SELF"]) . $return),
	canret=>array (label=>"Cancel",
			redirect=>dirname ($_SERVER["PHP_SELF"])),
	close=>array (label=>"Close",
			redirect=>dirname ($_SERVER["PHP_SELF"])),
);

$image_options = array (size=>$_REQUEST["_img_size"]);

list ($fs_input, $fs_action, $store, $valid, $success) =

	_app_process_fieldset (array (
		fieldset=>$fieldset_tasks,
		fs_options=>$fs_options,
		fs_primary_key=>"task_id",
		fs_action=>($_REQUEST["fs_action"] ?
				$_REQUEST["fs_action"] :
				"view"),
));

$_OBJECT_FIELDSET_CONTROL =_app_create_fieldset_object (array (
	fieldset_id=>"fs_tasks",
	db_conn=>$_GLOBAL_DBH,
	fieldset=>$fieldset_tasks,
	fs_action=>$fs_action,
	fs_input=>$fs_input,
	fs_link=>"fs_tasks.php?fs_action=view&fs_tab=main&task_id={$_REQUEST["task_id"]}",
	fs_options=>$fs_options,
));

$_OBJECT_IFACE_TABBING_PANEL->insert_container ($_OBJECT_FIELDSET_CONTROL);

?>
